<?php

namespace app\api\controller;

use think\admin\Controller;
use think\admin\helper\QueryHelper;
use think\facade\Request;
use think\facade\Config;
use app\member\model\ImsMcMembers;
use app\member\model\ImsEweiShopMember;

class Base extends Controller
{
    public function index()
    {
        echo "api index";
    }

    public function getMemberInfoByToken($token){

        $member = ImsEweiShopMember::mk()->where(['token'=>$token])->find();

        if (empty($member)) {
            $tokenService = new TokenService();
            $smid = $tokenService->verifyToken($token);
            $member = ImsEweiShopMember::mk()->where(['id'=>$smid])->find();
        }
        
        return $member;
    }

    public function echojson($code=1,$msg='error',$data=[]){
        echo json_encode([
            'code'=>$code,
            'data'=>$data,
            'msg'=>$msg
        ]);
        exit();
    }

    public static function getImageFullUrl($image='',$type=1){
        return get_image_full_url($image);
    }

    //不可逆加密函数
    public function encryption( $string ){
        return md5( sha1( $string ) );
    }

}
